package com.controller;

import com.entity.Airway;
import com.entity.Company;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping(value="/company")
public class CompanyController {
    //各航空公司航线图及其航班数jsp页面访问路径
    @RequestMapping(value = "/companyAirway")
    public String getCompanyAirway() {
        return "companyAirway";
    }

    /*
    autor：CYQ
    1.得到各航空公司的各航线及其航线数量（公司和航线去重）
    2.根据航空公司的总航线排行选取前十即可，也可以随便选几家公司（数量不限），echart显示公司名是根据后端传的公司list显示的，如： ['南方航空', '东方航空', '厦门航空', '中国国航', '海南航空', '四川航空', '成都航空', '深圳航空', '中国联合航空', '昆明航空']
    3.实体类的属性可根据以下例子修改
     */
    // //各航空公司航线图及其航班数jsp页面加载数据
    @RequestMapping("/loadCompanyAirway")
    @ResponseBody
    public ArrayList<Company> loadCompanyAirway() {
        ArrayList<Company> companyArrayList = new ArrayList<Company>();

        Company company1 = new Company("南方航空");
        ArrayList<Airway> airwayArrayList1 = new ArrayList<>();
        Airway airway1 =  new Airway("北京","广州",100);
        Airway airway2 =  new Airway("北京","深圳",90);
        Airway airway3 =  new Airway("上海","西安",80);
        Airway airway4 =  new Airway("天津","东莞",70);
        Airway airway5 =  new Airway("西宁","广州",60);
        airwayArrayList1.add(airway1);
        airwayArrayList1.add(airway2);
        airwayArrayList1.add(airway3);
        airwayArrayList1.add(airway4);
        airwayArrayList1.add(airway5);
        company1.setAirwayList(airwayArrayList1);
        companyArrayList.add(company1);

        Company company2 = new Company("厦门航空");
        ArrayList<Airway> airwayArrayList2 = new ArrayList<>();
        Airway airway6 =  new Airway("西安","北京",50);
        Airway airway7 =  new Airway("西安","上海",40);
        Airway airway8 =  new Airway("西安","广州",30);
        Airway airway9 =  new Airway("西安","西宁",20);
        Airway airway10 =  new Airway("西宁","银川",10);
        airwayArrayList2.add(airway6);
        airwayArrayList2.add(airway7);
        airwayArrayList2.add(airway8);
        airwayArrayList2.add(airway9);
        airwayArrayList2.add(airway10);
        company2.setAirwayList(airwayArrayList2);
        companyArrayList.add(company2);

        Company company3 = new Company("东方航空");
        ArrayList<Airway> airwayArrayList3 = new ArrayList<>();
        Airway airway11 =  new Airway("西宁","北京",200);
        Airway airway12 =  new Airway("西宁","郑州",300);
        Airway airway13 =  new Airway("西宁","鄂尔多斯",400);
        Airway airway14 =  new Airway("西宁","镇江",500);
        Airway airway15 =  new Airway("西宁","韶关",600);
        airwayArrayList3.add(airway11);
        airwayArrayList3.add(airway12);
        airwayArrayList3.add(airway13);
        airwayArrayList3.add(airway14);
        airwayArrayList3.add(airway15);
        company3.setAirwayList(airwayArrayList3);
        companyArrayList.add(company3);

        return companyArrayList;
    }
}
